class SceneManager {

	private static _instance : SceneManager = null;
	public static getInstance():SceneManager
	{
		if(this._instance == null)
		{
			this._instance = new SceneManager();
			this._instance.init();
		}
		return this._instance;
	}

	private m_mainScene:egret.DisplayObjectContainer = null;
	private m_runningScene:egret.DisplayObjectContainer = null;

	private init():void
	{
		this.m_mainScene = null;
		this.m_runningScene = null;
	}

	public setMainScene(_mainScene:egret.DisplayObjectContainer):void
	{
		this.m_mainScene = _mainScene;
	}

	public runScene(_scene:egret.DisplayObjectContainer):void
	{
		if(this.m_mainScene == null) return;
		if(_scene == null) return;
		if(this.m_runningScene != null) return;

		this.m_runningScene = _scene;
		this.m_mainScene.addChild(_scene);
	}

	public replaceScene(_scene:egret.DisplayObjectContainer):void
	{
		if(this.m_mainScene == null) return;
		if(_scene == null) return;
		if(this.m_runningScene == null)
		{
			this.runScene(_scene);
			return;
		}
		this.m_mainScene.removeChild(this.m_runningScene);
		this.m_runningScene = null;
		this.m_runningScene = _scene;
		this.m_mainScene.addChild(_scene);
	}

	public getRunningScene():egret.DisplayObjectContainer
	{
		return this.m_runningScene;
	}
}